package com.example.mykotlin.base.result

import com.mybatisflex.core.paginate.Page
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.Max
import jakarta.validation.constraints.Min

data class PageParam(
    @field:Min(value = 1, message = "当前查询页数从1开始")
    @field:Max(value = Int.MAX_VALUE.toLong(), message = "当前查询页数过大")
    @Schema(title = "当前查询页数从1开始")
    var pageNumber: Int? = 1,
    @field:Min(value = 10, message = "每页最少10条")
    @field:Max(value = 50, message = "每页最多50条")
    @Schema(title = "每页查询数量 最少10条，最多50条")
    var pageSize: Int? = 10
) {
    fun <T> page() = Page<T>((pageNumber ?: 1).toLong(), (pageSize ?: 10).toLong())
}



